package demo.componet.progress
{
	import laya.display.Sprite;
	import laya.ui.ProgressBar;
	
	/**
	 *@date 2017-2-16 上午10:17:52
	 *@author zhouhonghui
	 */
	public class GProgressBarBase extends ProgressBar
	{
		protected var _barMask:Sprite;
		public function GProgressBarBase(skin:String=null)
		{
			super(skin);
			
			
		}
		/**@inheritDoc */
		protected override function preinitialize():void
		{
			//预初始化
		}
		/** @inheritDoc **/
		protected override function createChildren():void
		{
			super.createChildren();
			_barMask = new Sprite();
		}
		protected override function initialize():void
		{
			super.initialize();
			_bar.mask = _barMask;
		}
		public override function set skin(value:String):void
		{
			super.skin = value;			
		}
		
		public override function set sizeGrid(value:String):void
		{
			_bg.sizeGrid = value;
		}
		
		/**
		 * @private
		 * 更改进度值的显示。
		 */
		protected override function changeValue():void {
			if (sizeGrid) {
				var grid:Array = sizeGrid.split(",");
				var top:int = Number(grid[0]);
				var left:Number = Number(grid[3]);
				var right:Number = Number(grid[1]);
				var max:Number = width - left - right;
				var sw:Number = max * _value;
				_bar.width = max;	
				_barMask.graphics.clear();
				_barMask.graphics.drawRect(0,0,sw,_bar.height,'#ff0000');
			} else { 
				_bar.width = width * _value;
			}
		}
		
	}
}